package cn.harry.modular.achievement.service.impl;

import cn.harry.modular.achievement.AchievementAuditVO;
import cn.harry.modular.achievement.domain.AchievementPatentApplication;
import cn.harry.modular.achievement.enums.AchievementStateEnums;
import cn.harry.modular.achievement.enums.NoticeTypeEnums;
import cn.harry.modular.achievement.mapper.AchievementPatentApplicationMapper;
import cn.harry.modular.achievement.service.AchievementPatentApplicationService;
import cn.harry.modular.achievement.service.NoticeService;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【achievement_patent_application(专利申请表)】的数据库操作Service实现
* @createDate 2025-05-06 09:33:38
*/
@Service
@RequiredArgsConstructor
public class AchievementPatentApplicationServiceImpl extends ServiceImpl<AchievementPatentApplicationMapper, AchievementPatentApplication>
    implements AchievementPatentApplicationService{

    private final NoticeService noticeService;
    @Override
    public boolean audit(AchievementAuditVO achievement) {
        String state = achievement.getState();
        AchievementPatentApplication item = getById(achievement.getId());
        item.setState(state);
        Long userId = item.getUserId();
        String title = item.getPatentTitle();

        String content = StrUtil.format("您的专利成果资源【{}】已被审核，审核结果为：{}", title, AchievementStateEnums.getDescByCode(state));
        noticeService.saveInfo(userId, content, NoticeTypeEnums.AUDIT_FEEDBACK);

        return updateById(item);
    }
}




